home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Base Documentation 1998 November
/
IRIX 6.5.2 Base Documentation November 1998.img
/
usr
/
share
/
catman
/
p_man
/
cat3
/
f90
/
cshift.z
/
cshift
Wrap
Text File
|
1998-10-30
|
5KB
|
121 lines
CSHIFT(3I) Last changed: 1-6-98
NNAAMMEE
CCSSHHIIFFTT - Performs a circular shift on an array expression
SSYYNNOOPPSSIISS
CCSSHHIIFFTT (([AARRRRAAYY==]_a_r_r_a_y,, [SSHHIIFFTT==]_s_h_i_f_t [,, [DDIIMM==]_d_i_m]))
IIMMPPLLEEMMEENNTTAATTIIOONN
UNICOS, UNICOS/mk, and IRIX systems
SSTTAANNDDAARRDDSS
Fortran 90
DDEESSCCRRIIPPTTIIOONN
The CCSSHHIIFFTT intrinsic function performs a circular shift on an array
expression of rank 1 or performs circular shifts on all the complete
rank 1 sections along a given array expression of rank 2 or greater.
Elements shifted out at one end are shifted in at the other end.
Different sections can be shifted by different amounts and in
different directions; positive for left shifts, negative for right
shifts.
CCSSHHIIFFTT accepts the following arguments:
_a_r_r_a_y Can be of any type. It must not be a scalar.
_s_h_i_f_t Must be integer. If _a_r_r_a_y has rank 1, _s_h_i_f_t must be a
scalar. Otherwise, _s_h_i_f_t must be scalar or have rank _n-1
and have
shape (_d , _d , ..., _d , _d , ..., _d ),
1 2 _d_i_m-1 _d_i_m+1 _n
where (_d , _d , ..., _d )
1 2 _n
is the shape of _a_r_r_a_y.
_d_i_m Must be a scalar. It is an integer with a value in the
range 1 <= _d_i_m <= _n, where _n is the rank of _a_r_r_a_y. If _d_i_m
is omitted, a value of 1 is assumed.
CCSSHHIIFFTT is a transformational function. The name of this intrinsic
cannot be passed as an argument.
RREETTUURRNN VVAALLUUEESS
The result is an array of the same type, type parameters, and shape as
_a_r_r_a_y.
If _a_r_r_a_y has rank 1, element _i of the result is
_a_r_r_a_y(1 + _m_o_d_u_l_o(_i + _s_h_i_f_t - 1, _s_i_z_e(_a_r_r_a_y))).
If _a_r_r_a_y has rank greater than 1,
section (_s , _s , ..., _s , : , _s , ..., _s )
1 2 _d_i_m-1 _d_i_m+1 _n
of the result has a value equal to
CCSSHHIIFFTT(_a_r_r_a_y (_s , _s , ..., _s , : , _s , ..., _s ), _s_h, 1),
1 2 _d_i_m-1 _d_i_m+1 _n
where _s_h is _s_h_i_f_t or
_s_h_i_f_t(_s , _s , ..., _s , _s , ..., _s )
1 2 _d_i_m-1 _d_i_m+1 _n
EEXXAAMMPPLLEESS
Example 1: If VV is a rank 1 array [[11,, 22,, 33,, 44,, 55,, 66]], the effect of
shifting VV circularly to the left by two positions is achieved by
CCSSHHIIFFTT (( VV,, SSHHIIFFTT == 22)), which has the value [[33,, 44,, 55,, 66,, 11,, 22]].
Specifying CCSSHHIIFFTT (( VV,, SSHHIIFFTT == --22 )) achieves a circular shift to the
right by two positions and has the value [[55,, 66,, 11,, 22,, 33,, 44]].
Example 2: The rows of an array of rank 2 can all be shifted by the
same amount or by different amounts. Assume MM is the following array:
| 1 2 3 |
| 4 5 6 |
| 7 8 9 |
The value of CCSSHHIIFFTT((MM,, SSHHIIFFTT ==--11,, DDIIMM == 22)) is as follows:
| 3 1 2 |
| 6 4 5 |
| 9 7 8 |
The value of CCSSHHIIFFTT((MM,, SSHHIIFFTT ==((// --11,, 11,, 00 //)),, DDIIMM == 22)) is as follows:
| 3 1 2 |
| 5 6 4 |
| 7 8 9 |
Example 3: NN is the following array:
| 1 2 3 4 |
| 5 6 7 8 |
| 9 10 11 12 |
The value of CCSSHHIIFFTT((NN,, SSHHIIFFTT ==--11,, DDIIMM == 11)) is as follows:
| 9 10 11 12 |
| 1 2 3 4 |
| 5 6 7 8 |
With an array section of multidimensional array NN, the value of
SSHHIIFFTT((NN((22::33,,22::44)),, SSHHIIFFTT==--11,, DDIIMM==11)) is as follows:
| 10 11 12 |
| 6 7 8 |
SSEEEE AALLSSOO
_I_n_t_r_i_n_s_i_c _P_r_o_c_e_d_u_r_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-2138, for the
printed version of this man page.